package com.ruoyi.system.service.impl;




import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.ComUser;
import com.ruoyi.system.utils.SecurityUserUtil;
import com.ruoyi.system.utils.WrapperUtils;
import com.ruoyi.system.mapper.SysFileMapper;
import com.ruoyi.system.domain.SysinFile;
import com.ruoyi.system.service.ISysFileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author LGY
 */
@Slf4j
@Service
public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysinFile> implements ISysFileService {

    @Autowired
    private SysFileMapper sysFileMapper;
    @Override
    public List<SysinFile> selectSysFileList(SysinFile sysFile)
    {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        if(!"admin".equals(loginUser.getUsername())){
            sysFile.setCreateBy(String.valueOf(loginUser.getUserId()));
        }
        Map map = JSON.parseObject(JSON.toJSONString(sysFile), Map.class);
        QueryWrapper<SysinFile> sysFileQueryWrapper = new QueryWrapper<>();
        //return sysFileMapper.selectList(WrapperUtils.MapAddEqualToQueryWrapper(sysFileQueryWrapper, map));

        QueryWrapper<SysinFile> queryWrapper = new QueryWrapper<>();
        WrapperUtils.MapAddEqualToQueryWrapper(queryWrapper, map);


        return baseMapper.selectList(queryWrapper);
    }

}

